package com.imooc.coupon.feign.hystrix;

import com.imooc.coupon.exception.CouponException;
import com.imooc.coupon.feign.SettlementClient;
import com.imooc.coupon.vo.CommonResponse;
import com.imooc.coupon.vo.SettlementInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Date 2021/11/12 14:30
 * @Author wangshbv
 * @Description 结算微服务熔断实现策略
 */
@Slf4j
@Component
public class SettlementClientHystrix implements SettlementClient {

    @Override
    public CommonResponse<SettlementInfo> computeRule(SettlementInfo settlementInfo)
            throws CouponException {
        log.error("[eureka-client-coupon-template] computeRule request error");
        settlementInfo.setEmploy(false);
        settlementInfo.setCost(-1D);

        return new CommonResponse<>(-1,
                "[eureka-client-coupon-template] computeRule request error",
                settlementInfo);
    }
}
